﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Logic.Packet.Factories
{
    public class PakServerFactory : IPakFactory
    {
        public T4CBasePak Parse(byte[] data)
        {
            T4CBasePak basicPak = new T4CBasePak(data);
            Type to = GetTypeToCreate(basicPak);
            return Activator.CreateInstance(to, basicPak) as T4CBasePak;
        }

        Type GetTypeToCreate(T4CBasePak basePak)
        {
            if (Packet.Paks.ServerPaks.ContainsKey(basePak.ActionID))
                return Packet.Paks.ServerPaks[basePak.ActionID];
            else
                return typeof(NotImplementedPak);
        }
    }
}
